import Vue from 'vue'
import vueRouter from 'vue-router'
import Login from "../view/Login";
import ECharts from "../components/HelloWorld"
import Home from "../view/Home";
import Chat from '../view/chat/FriendChat'
import AdminInfo from "@/view/AdminInfo";

Vue.use(vueRouter)

//l解决编程式路由往同一地址跳转时会报错的情况
/*const originalPush = vueRouter.prototype.push ;
const originalReplace = vueRouter.prototype.replace;
// push
vueRouter.prototype.push = function push(location,onResolve,onReject) {
    if (onResolve || onReject)
        return originalPush.call(this, location, onResolve, onReject);
    return originalPush.call(this, location).catch(err => err);
};
//replace
vueRouter.prototype.replace = function push(location, onResolve,onReject) {
    if (onResolve || onReject)
        return originalReplace.call( this, location, onResolve,onReject ) ;
    return originalReplace.call( this, location ) .catch(err => err) ;
};*/

const routes = [
    {
        path: '/',
        name: 'Login',
        component: Login,
        hidden:true
    },
    {
        path: '/echarts',
        name: 'ECharts',
        component: ECharts,
        hidden:true
    },
    {
        path: '/home',
        name: 'Home',
        component: Home,
        children:[
            {
                path: '/chat',
                name: '在线聊天',
                component: Chat
            },
            {
                path: '/userInfo',
                name: '个人信息',
                component: AdminInfo
            }
            ]
    },

   ]

const router = new vueRouter({
    routes
})
export default router
